package com.pn.controller;

import com.pn.entity.Client;
import com.pn.entity.Supply;
import com.pn.service.SupplyService;
import com.pn.utils.PageBean;
import com.pn.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("supply")
public class SupplyController {

    @Autowired
    private SupplyService supplyService;

    //显示供货商信息
    @GetMapping("/supply-page-list")
    public Result<PageBean<Supply>> supplyPageList(Supply supply){
        PageBean pageBean = supplyService.supplyPageList(supply);
        return Result.ok(pageBean);
    }

    //修改供货商
    @PutMapping("/supply-update")
    public Result supplyUpdate(@RequestBody Supply supply){
        return supplyService.supplyUpdate(supply);
    }


    //添加供货商
    @PostMapping("/supply-add")
    public Result supplyAdd(@RequestBody Supply supply){
        return supplyService.supplyAdd(supply);
    }

    //删除供货商
    @DeleteMapping("/supply-delete/{supplyId}")
    public Result supplyDelete(@PathVariable Integer supplyId){
        return supplyService.supplyDelete(supplyId);
    }

    //查看供货商编号是否存在
    @GetMapping("/supply-num-check")
    public Result supplyNumCheck(@RequestParam("supplyNum") String supplyNum1) {
        return supplyService.supplyNumCheck(supplyNum1);
    }
}
